package cn.dakaqi.member.service;

import cn.dakaqi.entities.Volunteer;
import cn.dakaqi.utils.exception.ServiceRuntimeException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

/**
 * Created by chunyang on 2016/4/13.
 */
public interface VolunteerDao extends PagingAndSortingRepository<Volunteer, Long>, JpaSpecificationExecutor<Volunteer>
{
    Volunteer findByVolunteerCode(String volunteerCode) throws ServiceRuntimeException;
    Volunteer findByMemberCode(String memberCode)throws ServiceRuntimeException;
    Volunteer findByUserId(Long userId) throws ServiceRuntimeException;
    Page<Volunteer> findByLocked(int locked, Pageable pageRequest)throws ServiceRuntimeException;
    Volunteer findByMobile(String oldMobile);
    Volunteer findByCardNO(String cardNO);

    @Query(nativeQuery = true, value = "select CODE as act from U_AREA_PROVINCE where NAME like %:province%")
    public String queryProvinceCode(@Param("province") String province);


}
